﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Faust.Andrew.MTG"
	x:Class="Faust.Andrew.MTG.DeckWindow"
	x:Name="Window"
	Title="DeckWindow" mc:Ignorable="d" Width="625" Background="{DynamicResource DefaultWindowBackground}" Icon="MTGManagerIcon.ico" PreviewDrop="Deck_PreviewDrop" AllowDrop="True" Closing="Window_Closing">
	<Window.Resources>
		<DataTemplate x:Key="CardTemplate">
			<Border x:Name="border" BorderBrush="Black" BorderThickness="1" Padding="2" HorizontalAlignment="Left" VerticalAlignment="Top" PreviewMouseLeftButtonDown="Card_PreviewMouseLeftButtonDown" PreviewMouseMove="Card_PreviewMouseMove">
			<Border.LayoutTransform>
				<TransformGroup>
					<ScaleTransform/>
					<SkewTransform/>
					<RotateTransform/>
					<TranslateTransform/>
				</TransformGroup>
			</Border.LayoutTransform>
			<StackPanel Height="Auto" Background="#FF555555" HorizontalAlignment="Left" VerticalAlignment="Top">
				<Image x:Name="image" Width="223" Height="310" Source="{Binding Card.ImageSource, Mode=OneWay}"/>
				<Grid Height="Auto">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="0.33*"/>
						<ColumnDefinition Width="0.33*"/>
						<ColumnDefinition Width="0.33*"/>
					</Grid.ColumnDefinitions>
					<StackPanel Margin="0" Orientation="Horizontal">
						<Label Content="Owned:" Margin="0,0,2,0" Foreground="White"/>
						<Label Content="{Binding Card.Quantity}" Foreground="White"/>
					</StackPanel>
					<ToggleButton x:Name="toggleButton" HorizontalAlignment="Right" Margin="0" Style="{DynamicResource BiggifyButtonTemplate}" VerticalAlignment="Center" Content="" ContentTemplate="{DynamicResource BiggifyButtonContentTemplate}" Grid.ColumnSpan="1" Grid.Column="2" Width="26" Height="26">
						<ToggleButton.LayoutTransform>
							<TransformGroup>
								<ScaleTransform/>
								<SkewTransform/>
								<RotateTransform/>
								<TranslateTransform/>
							</TransformGroup>
						</ToggleButton.LayoutTransform>
					</ToggleButton>
					<TextBox Text="{Binding Quantity, Converter={StaticResource IntToStringConverter}, Mode=TwoWay}" TextWrapping="Wrap" HorizontalAlignment="Center" Background="#2A302727" Foreground="#FFE2E2E2" Style="{DynamicResource DeckItemQuantityTextBoxTemplate}" Width="40" HorizontalContentAlignment="Center" Margin="0" VerticalAlignment="Center" Grid.Column="1"/>
				</Grid>
			</StackPanel>
		</Border>
		<DataTemplate.Triggers>
			<Trigger Property="IsChecked" Value="False" SourceName="toggleButton">
				<Setter Property="LayoutTransform" TargetName="border">
					<Setter.Value>
						<TransformGroup>
							<ScaleTransform ScaleX="1.0" ScaleY="1.0"/>
							<SkewTransform/>
							<RotateTransform/>
							<TranslateTransform/>
						</TransformGroup>
					</Setter.Value>
				</Setter>
			</Trigger>
			<Trigger Property="IsChecked" Value="True" SourceName="toggleButton">
				<Setter Property="LayoutTransform" TargetName="border">
					<Setter.Value>
						<TransformGroup>
							<ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
							<SkewTransform/>
							<RotateTransform/>
							<TranslateTransform/>
						</TransformGroup>
					</Setter.Value>
				</Setter>
			</Trigger>
		</DataTemplate.Triggers>
		</DataTemplate>
	</Window.Resources>

	<Grid x:Name="LayoutRoot" Margin="0">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="0.66*"/>
			<ColumnDefinition Width="3"/>
			<ColumnDefinition Width="0.33*"/>
		</Grid.ColumnDefinitions>
		<Menu Grid.ColumnSpan="3" Margin="0,0,0,5">
			<MenuItem Header="_File">
				<MenuItem Header="_Save" Click="Save_Click"/>
				<Separator/>
				<MenuItem Header="_Close" Click="Close_Click"/>
			</MenuItem>
		</Menu>
		<Grid x:Name="GridDeck" MinHeight="250" Margin="0" Grid.ColumnSpan="2" Grid.Row="1">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="*"/>
			</Grid.RowDefinitions>
			<ComboBox x:Name="cmbSort" HorizontalAlignment="Center" Margin="0,0,0,2" d:LayoutOverrides="Height" MinWidth="100" SelectionChanged="cmbSort_SelectionChanged">
				<ListBoxItem Content="Name"/>
				<ListBoxItem Content="Color"/>
				<ListBoxItem Content="Rarity"/>
				<ListBoxItem Content="Type"/>
				<ListBoxItem Content="Converted Mana Cost"/>
				<ListBoxItem Content="Owned"/>
				<ListBoxItem Content="Quantity"/>
			</ComboBox>
			<ListBox x:Name="lbDeck" Background="{x:Null}" BorderBrush="#FF433D3D" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemTemplate="{DynamicResource CardTemplate}" ItemsPanel="{DynamicResource CardLayoutTemplate}" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemContainerStyle="{DynamicResource CardItemContainerTemplate}" ItemsSource="{Binding Cards, Mode=Default}" Grid.Row="1" />
		</Grid>
		<GridSplitter HorizontalAlignment="Stretch" Grid.Column="1" Grid.Row="1"/>
		<TabControl Background="{x:Null}" Margin="0" Grid.Column="2" d:LayoutOverrides="Height" Grid.Row="1">
			<TabItem Header="Overview" Margin="0">
				<local:DeckStatistics x:Name="deckStatistics" Margin="0" Background="{DynamicResource ControlBoxBrush}"/>
			</TabItem>
			<TabItem Header="Description" Margin="0">
				<Grid Margin="0" Background="{DynamicResource ControlBoxBrush}">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition Width="*"/>
					</Grid.ColumnDefinitions>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="*"/>
					</Grid.RowDefinitions>
					<Label x:Name="lblDeckName" Margin="0" Content="Name:" d:LayoutOverrides="Width, Height"/>
					<TextBox x:Name="txtDeckName" Margin="0" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Grid.Column="1" Text="{Binding Name, Mode=TwoWay}"/>
					<CheckBox Grid.Row="1" Margin="0,5" Content="Is Constructed" IsChecked="{Binding IsConstructed, Mode=TwoWay}" />
					<Label x:Name="lblDeckDescription" Margin="0" Content="Description:" d:LayoutOverrides="Width, Height" Grid.Row="2" Grid.ColumnSpan="2"/>
					<TextBox x:Name="txtDeckDescription" Margin="0" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Grid.Row="3" Grid.ColumnSpan="2" AcceptsTab="True" AcceptsReturn="True" Text="{Binding Description, Mode=TwoWay}"/>
				</Grid>
			</TabItem>
		</TabControl>
	</Grid>
</Window>